import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CommonController } from './common/common.controller';
import { CommonService } from './common/common.service';
import { DepartmentController } from './department/department.controller';
import { Department } from './department/department.entity';
import { DepartmentService } from './department/department.service';
import { DictDataController } from './dictData/dictData.controller';
import { DictData } from './dictData/dictData.entity';
import { DictDataService } from './dictData/dictData.service';
import { DictTypeController } from './dictType/dictType.controller';
import { DictType } from './dictType/dictType.entity';
import { DictTypeService } from './dictType/dictType.service';
import { LogController } from './log/log.controller';
import { Log } from './log/log.entity';
import { LogService } from './log/log.service';
import { MenuController } from './menu/menu.controller';
import { Menu } from './menu/menu.entity';
import { MenuService } from './menu/menu.service';
import { PositionController } from './position/position.controller';
import { Position } from './position/position.entity';
import { PositionService } from './position/position.service';
import { RoleController } from './role/role.controller';
import { Role } from './role/role.entity';
import { RoleService } from './role/role.service';
import { UserController } from './user/user.controller';
import { User } from './user/user.entity';
import { UserService } from './user/user.service';

@Module({
  imports: [
    TypeOrmModule.forFeature([
      User,
      Role,
      Menu,
      Department,
      DictType,
      DictData,
      Log,
      Position,
    ]),
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (config: ConfigService) => ({
        secret: config.get('jwt.secretkey'),
        signOptions: {
          expiresIn: config.get('jwt.expiresIn'),
        },
      }),
      inject: [ConfigService],
    }),
  ],
  controllers: [
    CommonController,
    UserController,
    RoleController,
    MenuController,
    DepartmentController,
    DictTypeController,
    DictDataController,
    LogController,
    PositionController,
  ],
  providers: [
    CommonService,
    UserService,
    RoleService,
    MenuService,
    DepartmentService,
    DictTypeService,
    DictDataService,
    LogService,
    PositionService,
  ],
  exports: [
    CommonService,
    UserService,
    RoleService,
    MenuService,
    DepartmentService,
    DictTypeService,
    DictDataService,
    LogService,
    PositionService,
  ],
})
export class SystemModule {}
